<?php
error_reporting(E_ALL^E_NOTICE);
if($_POST){
    $str = '';
    if($_POST['type'] == 'list'){
        $files = $_POST['text'];
        $files = explode(PHP_EOL, $files);
        $files = array_unique($files);
        sort($files);
        foreach($files as $f){
            $str.= $f."<br>";
        }
    }elseif($_POST['type'] == 'dou'){
        $s = $_POST['text'];
        $str = join(" ", explode(PHP_EOL, $s));
    }
    
}


?>

<form method="POST">
<div>
<select name="type">
<option value="list">文件去重和排序</option>
<option value="dou">回车转换空格</option>

</select><button>提交</button>
</div>
<h3>文件列表:</h3>
<textarea name="text" style="width: 500px; height:300px"><?php echo $_POST['text']; ?></textarea>

<h3>结果：</h3>
<p ><?php echo $str; ?></p>

</form>